#include<bits/stdc++.h>
#define endl '\n'
#define debug(x) cerr<<#x<<':'<<x<<endl
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int N=1e6+5;
int px[4]={-1,1,0,0},py[4]={0,0,-1,1};
int n,m;
vector<vector<char> > a,ans;
void sol(int x,int y){
    a[x][y]='1';
    ans[x][y]=1;
    for(int i=0;i<4;i++) ans[x+px[i]][y+py[i]]=1;
}
signed main(){
    freopen("indian.in","r",stdin);
    freopen("indian.out","w",stdout);
    cin>>n>>m;
    a.resize(n+5);
    ans.resize(n+5);
    for(int i=0;i<=n+1;i++) a[i].resize(m+5),ans[i].resize(m+5);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(ans[i][j]||a[i][j]=='.') continue;
			if(!ans[i][j+1]&&a[i][j+1]=='#') sol(i,j+1);
			else if(a[i+1][j]=='#') sol(i+1,j);
			else sol(i,j);
		}
	}
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#') cout<<0;
            else cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}